package com.frxuexi.myroom.viewmodel

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.myroom.intent.UserIntent
import com.frxuexi.myroom.repository.UserRepo
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(private val userRepo: UserRepo):BaseViewModel<UserIntent>() {
    override fun handleIntent(it: UserIntent) {
        when(it){
            is UserIntent.register->{
                roomRequest(userRepo.register(it.user))
            }
            is UserIntent.login->{
                roomRequest(userRepo.login(it.name,it.pass,it.role))
            }
        }
    }
}